class Spreadsheet {
public:
    vector<map<int, int>> excel;

    pair<int, int> GetPos(string cell)
    {
        int col=cell[0]-'A';
        // cell=cell.substr(1); 
        int row=stoi(cell.substr(1));
        return {col, row};
    }
    Spreadsheet(int rows) {
        excel.resize(26);
    }
    
    void setCell(string cell, int value) {
        // int col, row;
        auto [col, row]=GetPos(cell);
        excel[col][row]=value; 
    }
    
    void resetCell(string cell) {
        auto [col, row]=GetPos(cell);
        excel[col][row]=0;
    }   
    
    int getValue(string formula) {
        int add=formula.find('+');
        string cell1=formula.substr(1, add-1);
        string cell2=formula.substr(add+1, formula.size());
        int val1=0, val2=0;

        if(isdigit(cell1[0]))
            val1=stoi(cell1);
        else
        {
            auto [col1, row1]=GetPos(cell1);
            val1=excel[col1][row1];
        }
        
        if(isdigit(cell2[0]))
            val2=stoi(cell2);
        else
        {
            auto [col2, row2]=GetPos(cell2);
            val2=excel[col2][row2];
        }
        return val1+val2;
    }
};

/**
 * Your Spreadsheet object will be instantiated and called as such:
 * Spreadsheet* obj = new Spreadsheet(rows);
 * obj->setCell(cell,value);
 * obj->resetCell(cell);
 * int param_3 = obj->getValue(formula);
 */